import config from "config";
import httpFetch from "share/httpFetch";

export default {
  search({ expenseTypeOid, classifyType, cycle, page = 0 }) {
    return httpFetch.get(`${config.baseUrl}/api/quato/list`, {
      expenseTypeOid,
      classifyType,
      cycle,
      page,
      size: 10,
    });
  },

  saveQuato({ expenseTypeOid, classifyType, cycle }) {
    return httpFetch.post(`${config.baseUrl}/api/quato/save`, {
      expenseTypeOid,
      classifyType,
      cycle,
    });
  },

  updateQuato({ id, expenseTypeOid, classifyType, cycle }) {
    return httpFetch.put(`${config.baseUrl}/api/quato/modify`, {
      id,
      expenseTypeOid,
      classifyType,
      cycle,
    });
  },

  getQuato({ quatoId }) {
    return httpFetch.get(`${config.baseUrl}/api/quato/getQuatoById`, {
      id: quatoId,
    });
    // return Promise.resolve({
    //   status: 200,
    //   data: {
    //     quatoId: '123',
    //     cycle: 2,
    //     classifyType: 1,
    //     expenseTypeOid: '0b967f35-de19-4dad-9627-4ef098198986'
    //   }
    // });
  },

  searchQuato({ keyword = "", quatoId, current = 1, size = 10 }) {
    return httpFetch.get(`${config.baseUrl}/api/quato/getDetailList`, {
      quatoId,
      keyword,
      page: current - 1,
      size
    });
  },

  saveDetailList(quatoDetailList) {
    return httpFetch.post(`${config.baseUrl}/api/quato/saveDetail`, {
      quatoDetailList,
    });
  },

  modifyDetail(params = {}) {
    return httpFetch.put(`${config.baseUrl}/api/quato/modifyDetail`, params);
  },

  deleteDetail(params = {}) {
    return httpFetch.delete(`${config.baseUrl}/api/quato/deleteDetail`, params);
  },

  disabledQuota(id) {
    return httpFetch.put(`${config.baseUrl}/api/quato/modifyQuato?id=${id}`);
  }
};
